//
// Created by 16933 on 2022/5/3.
//

#include "bsp_Wifi.h"


void Wifi_Server_Init(UART_HandleTypeDef *huart, uint8_t *pData,uint16_t Size)
{
    HAL_UART_Receive_DMA(huart,pData, Size);
    __HAL_UART_ENABLE_IT(huart,UART_IT_IDLE);
    HAL_UART_Transmit_DMA(huart,"AT+CWMODE=2\r\n",sizeof("AT+CWMODE=2\r\n"));

    while (!__HAL_UART_GET_FLAG(huart,UART_FLAG_TC))
    {
        ;
    }
    HAL_Delay(200);
    HAL_UART_Transmit_DMA(huart,"AT+RST\r\n",sizeof("AT+RST\r\n"));
    while (!__HAL_UART_GET_FLAG(huart,UART_FLAG_TC))
    {
        ;
    }
    HAL_Delay(200);
    HAL_UART_Transmit_DMA(huart,"AT+CWMODE=2\r\n",sizeof("AT+CWMODE=2\r\n"));
    while (!__HAL_UART_GET_FLAG(huart,UART_FLAG_TC))
    {
        ;
    }
    HAL_Delay(200);
    HAL_UART_Transmit_DMA(huart,"AT+CWSAP=\"HNBC\",\"11111111\",6,4\r\n",sizeof("AT+CWSAP=\"HNBC\",\"11111111\",6,4\r\n"));
    while (!__HAL_UART_GET_FLAG(huart,UART_FLAG_TC))
    {9
        ;
    }
    HAL_Delay(200);
    HAL_UART_Transmit_DMA(huart,"AT+CIPMUX=1\r\n",sizeof("AT+CIPMUX=1\r\n"));
    while (!__HAL_UART_GET_FLAG(huart,UART_FLAG_TC))
    {
        ;
    }
    HAL_Delay(200);
    HAL_UART_Transmit_DMA(huart,"AT+CIPSERVER=1,333\r\n",sizeof("AT+CIPSERVER=1,333\r\n"));
    while (!__HAL_UART_GET_FLAG(huart,UART_FLAG_TC))
    {
        ;
    }

}

void BlueTooth_Init(UART_HandleTypeDef *huart, uint8_t *pData,uint16_t Size)
{
    HAL_UART_Receive_DMA(huart,pData, Size);
    __HAL_UART_ENABLE_IT(huart,UART_IT_IDLE);
}